﻿using System.IO;
using System.Text;

namespace ICommonLibrary.Resource {

    public class AssemblyResource : IResource {

        public string Description { get; private set; }
        public string AssemblyString { get; private set; }
        public string ResourcePath { get; private set; }

        public AssemblyResource(string assemblyString, string resourcePath) {
            AssemblyString = assemblyString;
            ResourcePath = resourcePath;
            Description = string.Format("AssemblyResource[{0}, {1}]", AssemblyString, ResourcePath);
        }

        public Stream GetStream() {
            return AssemblyUtil.LoadResource(AssemblyString, ResourcePath);
        }

        public TextReader GetReader() {
            return new StreamReader(GetStream(), Encoding.UTF8);
        }

    }
}